package com.anda.logistics.interceptor;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import com.anda.logistics.model.SystemMenu;
import com.anda.logistics.service.SystemMenuService;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.Interceptor;

public class MenuInterceptor implements Interceptor {

	private static final long serialVersionUID = -5529271147946925805L;
	private SystemMenuService systemMenuService;

	@Override
	public void destroy() {
	}

	@Override
	public void init() {
	}

	@Override
	public String intercept(ActionInvocation invocation) throws Exception {
		ActionContext context = invocation.getInvocationContext();
		HttpServletRequest request =(HttpServletRequest) context.get(org.apache.struts2.StrutsStatics.HTTP_REQUEST);
		if (request.getParameter("sysmenuid") != null){
			SystemMenu menu = systemMenuService.getOne(Integer.parseInt(request.getParameter("sysmenuid")));
			System.out.println(menu);
		}
		return invocation.invoke();
	}

	public SystemMenuService getSystemMenuService() {
		return systemMenuService;
	}
	@Resource
	public void setSystemMenuService(SystemMenuService systemMenuService) {
		this.systemMenuService = systemMenuService;
	}
	
	

}
